import http from '@/utils/http'

const BASE_URL = '/testing/planJob'

export interface PlanJobResp {
  id: string
  projectId: string
  name: string
  caseId: string
  testType: string
  isDisabled: string
  executeTime: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface PlanJobDetailResp {
  id: string
  projectId: string
  name: string
  caseId: string
  testType: string
  isDisabled: string
  executeTime: string
  version: string
  status: string
  isDeleted: string
  createdBy: string
  updatedBy: string
  createdAt: string
  updatedAt: string
  createUserString: string
  updateUserString: string
}
export interface PlanJobQuery {
  version: string
  createdBy: string
  sort: Array<string>
}
export interface PlanJobPageQuery extends PlanJobQuery, PageQuery {}

/** @desc 查询计划任务列表 */
export function listPlanJob(query: PlanJobPageQuery) {
  return http.get<PageRes<PlanJobResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询计划任务详情 */
export function getPlanJob(id: string) {
  return http.get<PlanJobDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增计划任务 */
export function addPlanJob(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改计划任务 */
export function updatePlanJob(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除计划任务 */
export function deletePlanJob(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出计划任务 */
export function exportPlanJob(query: PlanJobQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
